﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DeliveryService
{
    public class BLAdvertising
    {
        public List<MAdvertising> GetAllAdvertising()
        {
            using (DeliveryDBDataContext db = new DeliveryDBDataContext())
            {
                var quary = db.Advertisings.OrderByDescending(s => s.AdvertisingId)
                                           .Select(s => new MAdvertising
                                                {
                                                    Id = s.AdvertisingId,
                                                    ADUrl = s.ADUrl,
                                                    ADImageUrl = s.Picture,
                                                    Title = s.Title,
                                                    Pointer = s.Pointer,
                                                    GoodsId = (int)(s.GoodsId.HasValue ? s.GoodsId : 0)
                                                });
                return quary.ToList();
            }
        }
    }
}